-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load proposals sequentially #1506
Conversation
… about an address just make a single request, don't requestWithRetries
✅ Deploy Preview for fractal-dev ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
d374c2f
to
ab359c0
Compare
Currently we're truncating Markdown in Proposal List card, which is a giant link. Not supposed to render anchor tags within anchor tags.
2a2794a
to
bec53f2
Compare
… file, extensive use of dependency injection
…trategy contracts
Inline the `loadAzoriusProposals` again so we can use a ref to track the current DAO and stop the sequential processing of proposals if the DAO changes.
@@ -92,7 +92,6 @@ | |||
"@testing-library/react": "^14.2.1", | |||
"@types/react": "^18.0.17", | |||
"@types/react-dom": "^18.0.6", | |||
"@types/remove-markdown": "^0.3.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed that this unused package was hanging around, so removed it.
@@ -89,7 +89,7 @@ export default function Markdown({ truncate, content, collapsedLines = 6 }: IMar | |||
maxWidth="100%" | |||
> | |||
<ReactMarkdown | |||
remarkPlugins={[remarkGfm]} | |||
remarkPlugins={truncate ? [] : [remarkGfm]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't try to render URLs as actual links if we're showing markdown in "truncate" mode.
We're using "truncate" when showing markdown in Proposal List cards, which are giant anchor tags, so we don't want to try to render more anchor tags within those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't have anything to do with the rest of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this bandaid, safe to remove. This was to try to make it wait a little longer before it tries to setup the listener. which is no longer needed as this work fixes the root problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most likely some leftovers, seems like those references are not needed here
useEffect(() => { | ||
if (!azoriusContractAddress || !baseContracts || !type) { | ||
return; | ||
} | ||
const azoriusContract = | ||
baseContracts.fractalAzoriusMasterCopyContract.asProvider.attach(azoriusContractAddress); | ||
const timeLockPeriodFilter = azoriusContract.filters.TimelockPeriodUpdated(); | ||
const timelockPeriodListener: TypedListener<TimelockPeriodUpdatedEvent> = timelockPeriod => { | ||
action.dispatch({ | ||
type: FractalGovernanceAction.UPDATE_TIMELOCK_PERIOD, | ||
payload: BigNumber.from(timelockPeriod), | ||
}); | ||
}; | ||
azoriusContract.on(timeLockPeriodFilter, timelockPeriodListener); | ||
return () => { | ||
azoriusContract.off(timeLockPeriodFilter, timelockPeriodListener); | ||
}; | ||
}, [azoriusContractAddress, action, baseContracts, type]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this event listener to new useAzoriusListeners
useEffect(() => { | ||
if (!azoriusContractAddress || !baseContracts || !type) { | ||
return; | ||
} | ||
const azoriusContract = | ||
baseContracts.fractalAzoriusMasterCopyContract.asProvider.attach(azoriusContractAddress); | ||
|
||
const timeLockPeriodFilter = azoriusContract.filters.TimelockPeriodUpdated(); | ||
const timelockPeriodListener: TypedListener<TimelockPeriodUpdatedEvent> = timelockPeriod => { | ||
action.dispatch({ | ||
type: FractalGovernanceAction.UPDATE_TIMELOCK_PERIOD, | ||
payload: BigNumber.from(timelockPeriod), | ||
}); | ||
}; | ||
azoriusContract.on(timeLockPeriodFilter, timelockPeriodListener); | ||
return () => { | ||
azoriusContract.off(timeLockPeriodFilter, timelockPeriodListener); | ||
}; | ||
}, [azoriusContractAddress, action, baseContracts, type]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copied line-for-line in useERC20LinearStrategy.ts
, so removed here. I removed it from the other file too, and it's now in useAzoriusListeners
.
@@ -48,6 +49,7 @@ export default function useDAOController() { | |||
useFractalTreasury(); | |||
useERC20Claim(); | |||
useSnapshotProposals(); | |||
useAzoriusListeners(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create the listeners.
| { | ||
type: FractalGovernanceAction.SET_AZORIUS_PROPOSAL; | ||
payload: FractalProposal; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new action for setting one single Azorius proposal into state
{ | ||
batch: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't hurt right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not at all. I think we will see these benefits when we conform more to the Wagmi patterns and hooks ie useContractsRead
const proposalExecutedFilter = azoriusContract.filters.ProposalExecuted(); | ||
const proposalExecutedEvents = await azoriusContract.queryFilter(proposalExecutedFilter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to re-fetch these events for each proposal, can just do it once way up above and pass the full array down here for filtering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of refactoring in here to deal with teasing out the slight differences between ERC20 strategy contract and ERC721 strategy contract.
This works really well for me. Load time of 1 (rather than multiple) proposal(s) feels quicker and they all come in in the right order (from new to late) I raised at standup my desire for more comms on load time but @adamgall highlighted he raised these above. This led me to create the card here - #1517 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, gonna approved. just some questions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this bandaid, safe to remove. This was to try to make it wait a little longer before it tries to setup the listener. which is no longer needed as this work fixes the root problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this bandaid, safe to remove. This was to try to make it wait a little longer before it tries to setup the listener. which is no longer needed as this work fixes the root problem
() => safeAPI.getSafeInfo(utils.getAddress(_daoAddress)), | ||
5, | ||
); | ||
safeInfo = await safeAPI.getSafeInfo(utils.getAddress(_daoAddress)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been here for a long time. This was to safe guard against network hiccups. But yeah generally probably safe to remove
{ | ||
batch: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not at all. I think we will see these benefits when we conform more to the Wagmi patterns and hooks ie useContractsRead
export const decodeTransactions = async ( | ||
_decode: (value: string, to: string, data?: string | undefined) => Promise<DecodedTransaction[]>, | ||
_transactions: MetaTransaction[], | ||
) => { | ||
const decodedTransactions = await Promise.all( | ||
_transactions.map(async tx => _decode(tx.value.toString(), tx.to, tx.data)), | ||
); | ||
return decodedTransactions.flat(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did this appear from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just moved it into azorius.ts
because there was another new file (useAzoriusListeners.ts
) that needed it.
Closes #1509
Closes #1457
Closes #1464
User facing changes
Behind the scenes changes
useAzoriusProposals
, but alsouseERC20LinearStrategy
anduseERC721LinearStrategy
) into their own new top-level hook,useAzoriusListeners
Voted
events orProposalExecuted
events for each proposal. Instead, fetch them all just once before processing each proposal. Because they're not indexed, we have to just get all of them anyway. So just pass them down into the proposal processing and filter the same static set per proposal.useAzoriusProposals
, then check outazorius.ts
, then check outuseAzoriusListeners
, then check out the other little things strewn around.Potential follow up work
Testing